<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definition" 
  xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:camunda="http://camunda.org/schema/1.0/bpmn"
  targetNamespace="Examples">
  
  <process id="miParallelScriptTask" isExecutable="true">
  
    <startEvent id="theStart" />
    <sequenceFlow id="flow1" sourceRef="theStart" targetRef="miScriptTask" />
    
    <scriptTask id="miScriptTask" scriptFormat="groovy">
      <multiInstanceLoopCharacteristics isSequential="false">
        <loopCardinality>${nrOfLoops}</loopCardinality>
      </multiInstanceLoopCharacteristics>
      <script>
        <![CDATA[
	        def processInstance = execution.getProcessInstance()
	        def int sum = processInstance.getVariable("sum")
	        processInstance.setVariable("sum", sum + loopCounter)
        ]]>
      </script>
    </scriptTask>
    
    <sequenceFlow id="flow3" sourceRef="miScriptTask" targetRef="waitState" />
    <receiveTask id="waitState" />
    
     <sequenceFlow id="flow4" sourceRef="waitState" targetRef="theEnd" />
    <endEvent id="theEnd" />
    
  </process>

</definitions>